﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using TTQT.TTQT_Code;
using System.Web.Services;

public partial class NewsLetter : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        string type = Request.QueryString["type"];
        type = TTQT.TTQT_Code.TTQTCommon.isNull(type, "");
        string data = Request.QueryString["data"];
        if(string.IsNullOrEmpty(type))// List san pham trong gio hang
        {
            Response.ContentType = "text/html;level=1";
            Response.Write("0");
            return;
        }
        if (type.Equals("newmail"))//Luu dia chi email nay vao.
        {
            string kq = "1";
            SqlConnection conn = new SqlConnection(TTQTCommon.DBConnectionString);
            SqlCommand cmd = new SqlCommand("SanPham_Email_Add", conn);
            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Parameters.AddWithValue("@email", data);
            try
            {
                conn.Open();
                kq = cmd.ExecuteScalar().ToString();
            }
            catch (Exception exxx)
            { }
            finally
            {
                if (conn.State == ConnectionState.Open) conn.Close();
                conn.Dispose();
                cmd.Dispose();
            }

            Response.ContentType = "text/html;level=1";
            //string jsonKQ = new System.Web.Script.Serialization.JavaScriptSerializer().Serialize(gioHang.sanPhamList);
            Response.Write(kq);
        }
    }
}
